import java.io.File;
import java.io.IOException;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) {
        File f = new File("test.txt");
        if(f.exists()){
            System.out.println("文件存在");
        }else{
            System.out.println("文件不存在");
            try{
                f.createNewFile();
            }catch (IOException e){
                e.printStackTrace();
            }
        }
        File f2 = new File("src","Main.java");
        System.out.println("文件的路径："+ f2.getAbsolutePath());
        if(f2.exists()){
            System.out.println("Main.java文件存在");
            System.out.println(f2.canRead());
            System.out.println(f2.canWrite());
            System.out.println(f2.canExecute());
            System.out.println(f2.getParent());
            System.out.println(f2.getName());
            System.out.println(f2.getPath());
            System.out.println(f2.length());
        }else {
            System.out.println("Main.java文件不存在");
        }
        File f3 = new File("DIR");
        if(f3.mkdir()){
            System.out.println("目录创建成功");
        } else{
            System.out.println("目录创建不成功");
        }
        String[] filenames = f3.list();
        if(filenames != null) {
            for (String item : filenames) {
                System.out.println(item);
            }
        }
        System.out.println("---------------------");
        FileFilter filter = new FileFilter();
        String[] filteredFileNames = f3.list(filter);
        if(filteredFileNames != null){
            for (String item : filteredFileNames) {
                System.out.println(item);
            }
        }

        }
    }